package com.taiyi.renaissancemall.Utils;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.taiyi.renaissancemall.R;
import com.zhouwei.mzbanner.holder.MZViewHolder;

public class RoundBannerViewHolder implements MZViewHolder<String> {
    private ImageView mImageView;
    RoundedCorners roundedCorners = new RoundedCorners(100);

    private Context context;

    @Override
    public View createView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.layout_class_banner, null);
        mImageView = (ImageView) view.findViewById(R.id.img_class_banner);
        return view;
    }

    @Override
    public void onBind(Context context, int position, String data) {

//        RequestOptions requestOptions = new RequestOptions().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.RESOURCE).transform(roundedCorners).dontAnimate();
        RequestOptions transform = GlideOptionsManager.getInstance().transform(roundedCorners);
        // 数据绑定
        Glide.with(context).load(data).apply(transform).into(mImageView);
    }
}
